<?php

declare (strict_types = 1);

namespace app\console\service;

use app\common\library\helper;
use app\console\library\Tools;
use app\common\service\BaseService;
use app\console\model\UserCoupon as UserCouponModel;
use think\facade\Log;

/**
 * 服务类：用户优惠券
 * Class Order
 * @package app\console\service
 */
class UserCoupon extends BaseService
{
    /**
     * 设置优惠券过期状态
     * @param int $storeId
     * @return bool
     */
    public function setExpired(): bool
    {
        $model = new UserCouponModel;
        // 获取已过期的优惠券ID集
        $couponIds = $model->getExpiredCouponIds();
        Log::channel('command')->write('设置过期的优惠券ID：'.helper::jsonEncode($couponIds));
        if(!empty($couponIds)){
            // 更新已过期状态
            return $model->setIsExpire($couponIds);
        }
        return true;
    }
}